home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Maths & Calculations / count-down-to-xmasneve.izs < prev    next >
Text File  |  2005-07-20  |  7KB  |  226 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Count down to Christmas and new years eve
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>The below script will count down to Christmas and New Years Eve
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>Counters<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <!-- Step 1: Paste the following into the <head> section of your page: -->
  14. <script Language="JavaScript">
  15. var timerID = null;
  16. var timerRunning = false;
  17. function stopclock (){
  18.         if(timerRunning)
  19.                 clearTimeout(timerID);
  20.         timerRunning = false;
  21. }
  22.  
  23. function startclock () {
  24.         // Make sure the clock is stopped
  25.         stopclock();
  26.         showtime();
  27. }
  28.  
  29. function showtime () {
  30.         var now = new Date();
  31.         var hours = now.getHours();
  32.         var minutes = now.getMinutes();
  33.         var seconds = now.getSeconds();
  34.  
  35.         var date = now.getDate();
  36.         var month = now.getMonth() + 1;
  37.         var year = now.getYear();
  38.         if (year < 1000)
  39.          year+=1900
  40.         
  41.         var timeValue = "" + ((hours < 10 ) ? "0" : "") + hours
  42.         // var timeValue = "" + ((hours >12) ? hours -12 :hours)
  43.         timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  44.         timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  45.         // timeValue += (hours >= 12) ? " P.M." : " A.M."
  46.         
  47.         
  48.  
  49.  
  50.          if (seconds == 0) {
  51.         window.status = "New minute!";
  52.         document.clock.face.value = "New minute!";
  53.          }
  54.         if (minutes == 0 && seconds == 0) {
  55.         window.status = "New hour!";
  56.         document.clock.face.value = "New hour!";
  57.         
  58.          }
  59.         if (hours == 0 && minutes == 0 && seconds == 0) {
  60.         window.status = "Midnight!";
  61.         document.clock.face.value = "Midnight!";
  62.          }
  63.  
  64.        else if (seconds > 0) {
  65.         document.clock.face.value = timeValue + "  " + date + "/" +  month + "-" + year;        
  66.         window.status = timeValue + "  The Xact time according to your computer clock!     "  + date + "/" + month + "-" + year;
  67.                        }
  68.  
  69.         nextXmas = new Date("December 25, 2000")
  70.         nextXmas.setYear(year)
  71.         msPerDay = 24 * 60 * 60 * 1000 ; // Number of milliseconds per day
  72.         daysLeft = (nextXmas.getTime() - now.getTime()) / msPerDay;
  73.         daysLeft = Math.round(daysLeft);
  74.         document.Frame2.Xmas.value =  daysLeft + " days until Christmas Eve!";
  75.         
  76.         nextXmas = new Date("December 31, 2000")
  77.         nextXmas.setYear(year)
  78.         msPerDay = 24 * 60 * 60 * 1000 ; // Number of milliseconds per day
  79.         daysLeft = (nextXmas.getTime() - now.getTime()) / msPerDay;
  80.         daysLeft = Math.round(daysLeft);
  81.         document.Frame3.NewYear.value = daysLeft + " days until New Years Eve!";
  82.                     
  83.         timerID = setTimeout("showtime()",1000);
  84.  
  85.         timerRunning = true;
  86. }
  87. </script>
  88. <!-- Step 2: Paste the following into the <body> section of your page: -->
  89. <CENTER>
  90. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  91. <TR><TD>
  92. <form name="clock" onSubmit="0">
  93. <input type="textarea" name="face" size=20 value="Java">
  94. </TD></TR></table>
  95. </form>  
  96.  
  97. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  98. <TR><TD>
  99. <form name="Frame2" onSubmit="0">
  100. <input type="textarea" name="Xmas" size=50 value="Java">
  101. </TD></TR></table>
  102. </form>  
  103.  
  104. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  105. <TR><TD>
  106. <form name="Frame3" onSubmit="0">
  107. <input type="textarea" name="NewYear" size=50 value="Java">
  108. </TD></TR></table>
  109. </form>  
  110. </CENTER>
  111. <!-- Step 3: Finally, insert the following code into the <body> tag itself, like the following: -- >
  112.  
  113. <body onLoad="startclock()">
  114.  
  115. <!-- END OF SCRIPT -->
  116. <!/SCRIPT>
  117.  
  118. <!PREVIEW>
  119. <!-- START OF SCRIPT -->
  120. <!-- Step 1: Paste the following into the <head> section of your page: -->
  121. <script Language="JavaScript">
  122. var timerID = null;
  123. var timerRunning = false;
  124. function stopclock (){
  125.         if(timerRunning)
  126.                 clearTimeout(timerID);
  127.         timerRunning = false;
  128. }
  129.  
  130. function startclock () {
  131.         // Make sure the clock is stopped
  132.         stopclock();
  133.         showtime();
  134. }
  135.  
  136. function showtime () {
  137.         var now = new Date();
  138.         var hours = now.getHours();
  139.         var minutes = now.getMinutes();
  140.         var seconds = now.getSeconds();
  141.  
  142.         var date = now.getDate();
  143.         var month = now.getMonth() + 1;
  144.         var year = now.getYear();
  145.         if (year < 1000)
  146.          year+=1900
  147.         
  148.         var timeValue = "" + ((hours < 10 ) ? "0" : "") + hours
  149.         // var timeValue = "" + ((hours >12) ? hours -12 :hours)
  150.         timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  151.         timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  152.         // timeValue += (hours >= 12) ? " P.M." : " A.M."
  153.         
  154.         
  155.  
  156.  
  157.          if (seconds == 0) {
  158.         window.status = "New minute!";
  159.         document.clock.face.value = "New minute!";
  160.          }
  161.         if (minutes == 0 && seconds == 0) {
  162.         window.status = "New hour!";
  163.         document.clock.face.value = "New hour!";
  164.         
  165.          }
  166.         if (hours == 0 && minutes == 0 && seconds == 0) {
  167.         window.status = "Midnight!";
  168.         document.clock.face.value = "Midnight!";
  169.          }
  170.  
  171.        else if (seconds > 0) {
  172.         document.clock.face.value = timeValue + "  " + date + "/" +  month + "-" + year;        
  173.         window.status = timeValue + "  The Xact time according to your computer clock!     "  + date + "/" + month + "-" + year;
  174.                        }
  175.  
  176.         nextXmas = new Date("December 25, 2000")
  177.         nextXmas.setYear(year)
  178.         msPerDay = 24 * 60 * 60 * 1000 ; // Number of milliseconds per day
  179.         daysLeft = (nextXmas.getTime() - now.getTime()) / msPerDay;
  180.         daysLeft = Math.round(daysLeft);
  181.         document.Frame2.Xmas.value =  daysLeft + " days until Christmas Eve!";
  182.         
  183.         nextXmas = new Date("December 31, 2000")
  184.         nextXmas.setYear(year)
  185.         msPerDay = 24 * 60 * 60 * 1000 ; // Number of milliseconds per day
  186.         daysLeft = (nextXmas.getTime() - now.getTime()) / msPerDay;
  187.         daysLeft = Math.round(daysLeft);
  188.         document.Frame3.NewYear.value = daysLeft + " days until New Years Eve!";
  189.                     
  190.         timerID = setTimeout("showtime()",1000);
  191.  
  192.         timerRunning = true;
  193. }
  194. </script>
  195. <!-- Step 2: Paste the following into the <body> section of your page: -->
  196. <CENTER>
  197. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  198. <TR><TD>
  199. <form name="clock" onSubmit="0">
  200. <input type="textarea" name="face" size=20 value="Java">
  201. </TD></TR></table>
  202. </form>  
  203.  
  204. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  205. <TR><TD>
  206. <form name="Frame2" onSubmit="0">
  207. <input type="textarea" name="Xmas" size=50 value="Java">
  208. </TD></TR></table>
  209. </form>  
  210.  
  211. <TABLE BORDER=4 CELLPADDING=0.5 CELLSPACING=0.5>
  212. <TR><TD>
  213. <form name="Frame3" onSubmit="0">
  214. <input type="textarea" name="NewYear" size=50 value="Java">
  215. </TD></TR></table>
  216. </form>  
  217. </CENTER>
  218. <!-- Step 3: Finally, insert the following code into the <body> tag itself, like the following: -- >
  219.  
  220. <body onLoad="startclock()">
  221.  
  222.  
  223. <!-- END OF SCRIPT -->
  224. <!/PREVIEW>
  225.  
  226. <!RELATED>NONE<!/RELATED>